# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：   cache_manager
   Author :      wuqianyong
   date：        2019/2/12
-------------------------------------------------
   Change Activity:
                   2017/4/1:
-------------------------------------------------
Description :
 

"""
__author__ = 'wuqianyong'
# from django.core.cache import cache
# import json
from extra_apps.common_log import Log
# import time
import redis
from extra_apps.envs import deploy_env
from extra_apps.config.cache_config import REDIS_CONF

# import pickle
#
redis_url = "redis://:{}@{}:{}/{}".format(REDIS_CONF.get(deploy_env).get("password"),
                                          REDIS_CONF.get(deploy_env).get("host"),
                                          REDIS_CONF.get(deploy_env).get("port"),
                                          REDIS_CONF.get(deploy_env).get("db"))
Log.info("Cache 配置为：{}".format(redis_url))
# RedisPool = redis.ConnectionPool.from_url(redis_url)
# redis_conn = redis.Redis(connection_pool=RedisPool,decode_responses=True)
redis_conn = redis.Redis.from_url(redis_url, decode_responses=True)

if __name__ == '__main__':
    detail_all_key = "cbirc:task:detail_all"

    url = redis_conn.spop(detail_all_key)
    while url:
        Log.info('url:{}'.format(url))
        url = redis_conn.spop(detail_all_key)


    print(redis_conn.keys("*"))
    # print(redis_conn.hget("za_direct:v1:task_id",'http://www.babytree.com/ask/myqa__view~mlist,tab~D'))
